//删除数组的一项
function removeArrayItemByItem(item,array){
	for(var i = 0; i < array.length; i++) {
        if(array[i] == item) {
            array.splice(i,1);
        }
    }
	return array;
}

//根据下标删除数组的一项
function removeArrayItemByIndex(index,array){
	array.splice(index,1);
	return array;
}

//判断一项存在数组之中的第几项
function searchIndexByItem(item,array){
	for(var i = 0;i<array.length;i++){
		if(item==array[i]){
			return i;
		}
	}
}
///删除地图中的Popup
 function removePopupsByArray(array) {
    for (var i = 0; i < array.length; i++) {
        map.removePopup(array[i]);
    }
}

//判断一项是否存在于数组之中
function itemExistArray(item,array){
	for(var i = 0;i<array.length;i++){
		if(item==array[i]){
			return true;
		}
	}
	return false;
}
// 设置 select默认选中
function setSltDefaultVal(sltid, value) {
	var slt = document.getElementById(sltid) == null ? parent.document
			.getElementById(sltid) : document.getElementById(sltid);
	if(slt==null){
		return;
	}
	for (var i = 0; i < slt.length; i++) {
		if (slt[i].value == value){
			slt.selectedIndex = i;
			break;
		}
	}
}
//定义点的结构体
function point(){
	 this.x=0;
	 this.y=0;
}
//
//经纬度转墨卡托
/*
param: point_lonLat_x 经度  ；point_lonLat_y 纬度
*/
function lonLat2Mercator(point_lonLat_x,point_lonLat_y){
	var mercator = new point();
    var x = point_lonLat_x*20037508.34/180;
    var y = Math.log(Math.tan((90+point_lonLat_y)*Math.PI/360))/(Math.PI/180);
    y = y *20037508.34/180;
    mercator.x = x;
    mercator.y = y;
    return mercator ;
}
//墨卡托转经纬度
function Mercator2lonLat(point_mercator_x,point_mercator_y)
{
    var lonLat = new point();
    var x = point_mercator_x/20037508.34*180;
    var y = point_mercator_y/20037508.34*180;
    y= 180/Math.PI*(2*Math.atan(Math.exp(y*Math.PI/180))-Math.PI/2);
    lonLat.x = x;
    lonLat.y = y;
    return lonLat;
}
function changeZhdTypeByCode(code){
	var type = "暂无";
	switch(code){
	case "00": type = "危险斜坡";break;
	case "01": type = "滑坡";break;
	case "02": type = "崩塌";break;
	case "03": type = "泥石流";break;
	case "04": type = "岩溶塌陷";break;
	case "05": type = "采空塌陷";break;
	case "06": type = "地裂缝";break;
	case "07": type = "地面沉降";break;
	case "08": type = "塌岸";break;
	case "09": type = "高切坡";break;
	case "10": type = "危岩体";break;
	}
	return type;
}
function getOperTypeZhdByCode(code){
	var type = "十万调查点";
	switch(code){
	case "1": type = "十万调查点";break;
	case "2": type = "五万调查点";break;
	case "3": type = "应急调查点";break;
	case "4": type = "群测群防点";break;
	case "5": type = "重大灾害点";break;
	case "6": type = "应急监测点";break;
	case "new": type="新增点";break;
	}
	return type;
}
function getZhdImageAndFilePathByCode(code){
	var type = "10w";
	switch(code){
	case "1": type = "10w";break;
	case "2": type = "5w";break;
	case "3": type = "yjdc";break;
	case "4": type = "qcqf";break;
	case "5": type = "zdzh";break;
	case "6": type = "yjcj";break;
	}
	return type;
}
/////POP遮挡问题的解决   
////////////////////解决opnelayers的popup显示问题的方法//////////////////////////////////////////////////
catchPopupsZIndex = function(){
	var zindexArray = [];
	var length = map.popups.length;
	for(var i = 0;i<length;i++){
		var zindex = map.popups[i].div.style.zIndex;
		zindexArray.push(zindex);
	}
	var maxZindex = zindexArray.sort(function(a,b){
		return a-b;
	});
	var max = maxZindex[maxZindex.length-1];
	return max;
}


//函数主入口
showCurrentPopup = function(map,popupObj){
	debugger;
	var curMax = popupObj.div.style.zIndex;
	var max = catchPopupsZIndex();
	var lastPopupObj = map.popups[map.popups.length-1];
	var index = searchIndexByItem(popupObj,map.popups);
	//先将这个在数组中删除
	removeArrayItemByIndex(index,map.popups);
	for(var i = index;i<map.popups.length;i++){
		map.popups[i].div.style.zIndex = map.popups[i].div.style.zIndex-1;
	}
	popupObj.div.style.zIndex = max;
	map.popups.push(popupObj);
}

//根据下标删除数组的一项
removeArrayItemByIndex =function(index,array){
	array.splice(index,1);
	return array;
};


//判断一项存在数组之中的第几项
searchIndexByItem= function(item,array){
	for(var i = 0;i<array.length;i++){
		if(item==array[i]){
			return i;
		}
	}
}




	